package com.wing.enterprise.feign;

import com.wing.common.utils.JsonResult;
import com.wing.common.utils.PageResult;
import com.wing.enterprise.company.model.entity.Company;
import com.wing.enterprise.company.model.entity.SystemEnterpriseVO;
import com.wing.enterprise.device.entity.Device;
import com.wing.enterprise.device.request.DeviceForm;
import com.wing.enterprise.device.response.DeviceVO;
import com.wing.enterprise.device.response.ProcessDeviceVO;
import com.wing.enterprise.invoicing.model.entity.TransportCompany;
import com.wing.enterprise.order.model.ScanDeliveryVo;
import com.wing.enterprise.product.model.entity.*;
import com.wing.enterprise.product.model.request.*;
import com.wing.enterprise.product.model.response.*;
import com.wing.enterprise.res.ReceiptRecord;
import com.wing.enterprise.res.ReceiptRecordDetail;
import com.wing.enterprise.sell.model.entity.Order;
import com.wing.enterprise.sell.model.response.OrderVO;
import com.wing.enterprise.storage.model.PalletBoxSkuItermForm;
import com.wing.enterprise.system.SystemOfficialInfo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@FeignClient(name = "${enterprise.appName}",fallback = EnterpriseClientFallback.class)
public interface EnterpriseClient {
    @GetMapping("/product/admin/productDetail/getProductDetailBySkuCode")
    JsonResult<ProductDetailVO> getProductDetailBySkuCode(@RequestParam("skuCode") String skuCode);

    /**
     *查询产品明细
     * @param skuCode
     * @return
     */
    @GetMapping("/product/admin/productDetail/getProductInfoBySkuCode")
    JsonResult<ProductDetailVO> getProductInfoBySkuCode(@RequestParam("skuCode") String skuCode);

    @GetMapping("/product/admin/productUnit/getProductUnitById")
    JsonResult<ProductUnitVO> getProductUnitById(@RequestParam("productUnitId") Long productUnitId);

    @GetMapping("/product/admin/productPack/getProductPackById")
    JsonResult<ProductPackVO> getProductPackById(@RequestParam("packId") Long packId);

    @GetMapping("/product/admin/productPackLabel/getProductPackLabelById")
    JsonResult<ProductPackLabelVO> getProductPackLabelById(@RequestParam("packLabelId") Long packLabelId);

    @GetMapping("/product/admin/productPackLabel/getProductPackLabelVOList")
    JsonResult <ProductPackLabelVO> getProductPackLabelVOList(@RequestParam("code") String code, @RequestParam("type") Integer type);

    @GetMapping("/order/admin/cabInventoryProduct/list")//在库产品
    PageResult<CabInventoryProduct> getInventoryProductList(@RequestHeader(value = "secret", required = false) String secret
            , @RequestParam(value = "page", defaultValue = "1") Integer page
            , @RequestParam(value = "limit", defaultValue = "10") Integer limit
            , @RequestParam(value = "sort", defaultValue = "create_time") String sort
            , @RequestParam(value = "order", defaultValue = "asc") String order);

    //查询所有入库单计划下的包装条码
    @GetMapping("/product/admin/productPackLabel/getInventoryPackLabelPageList")
    PageResult <ProductPackLabelVO> getInventoryPackLabelPageList(@RequestHeader(value = "secret", required = false) String secret
            , @RequestParam(value = "page", defaultValue = "1") Integer page
            , @RequestParam(value = "limit", defaultValue = "10") Integer limit
            , @RequestParam(value = "sort", defaultValue = "create_time") String sort
            , @RequestParam(value = "order", defaultValue = "asc") String order
            , @RequestParam(value = "planId", required = false) Long productTypeId);
    //打印条码
    @GetMapping("/product/admin/productPackLabel/getBarCode")
    JsonResult<String> getBarCode(@RequestParam(value = "code") String code);
    /**
     * 扫描包装条码
     * @param code
     * @return
     */
    @GetMapping("/product/admin/productPackLabel/getByCode")
    JsonResult <ProductPackLabelVO> getPackLabelVOByCode(@RequestParam("labelCode") String labelCode, @RequestParam("loadPlanId") Long loadPlanId);

    @GetMapping("/product/admin/productPackLabel/getLabelByCode")
    JsonResult <ProductPackLabelVO> getLabelByCode(@RequestParam("labelCode") String labelCode);

    @PutMapping("/product/admin/productPackLabel/updateProductPackLabel")
    JsonResult updateProductPackLabel(@RequestBody ProductPackLabelVO productPackLabelVO);

    @PostMapping("/product/admin/productPackLabel/extractLabel4InventoryIn")
    JsonResult<ProductPackLabelForm> extractPackLabel(@RequestParam(value = "code") String code, @RequestParam(value = "extract") Integer extract, @RequestParam(value = "addCount") Integer addCount);

    @PostMapping("/product/admin/productPackLabel/extractLabel4InventoryIn2")
    JsonResult<ProductPackLabelForm> extractPackLabel2(@RequestParam(value = "code") String code, @RequestParam(value = "extract") Integer extract, @RequestParam(value = "addCount") Integer addCount, @RequestParam(value = "boxId") Long boxId, @RequestParam(value = "warehouseId") Long warehouseId, @RequestParam(value = "areaId") Long areaId, @RequestParam(value = "shelfId") Long shelfId, @RequestParam(value = "spaceId") Long spaceId);

    @PostMapping("/product/admin/productPackLabel/extractLabel4InventoryOut")
    JsonResult<ProductPackLabelForm> extractPackLabel4InventoryOut(@RequestParam(value = "code") String code, @RequestParam(value = "extract") Integer extract, @RequestParam(value = "addCount") Integer addCount);

    @GetMapping("/product/admin/product/getProductById")
    JsonResult<ProductVO> getProductById(@RequestParam("productId") Long productId);

    @GetMapping("/product/admin/productType/getProductTypeVoById")
    JsonResult<ProductTypeVO> getProductTypeVoById(@RequestParam("productTypeId") Long productTypeId);

    @GetMapping("/product/admin/productDetail/getProductDetailPageList")
    PageResult<ProductDetailVO> getProductDetailPageList();

    /**
     * 查询所有产品类型
     * @return
     */
    @GetMapping("/product/admin/productType/getProductTypeVOAll")
    JsonResult getProductTypeVOAll();

    /**
     * 查询所有产品分类
     * @return
     */
    @GetMapping("/product/admin/productCategory/getAll")
    JsonResult getProductCategory();

    /**
     * 添加包装码记录数据
     * @param productPackLabelOut
     * @return
     */
    @PostMapping("/product/admin/productPackLabelOut/addProductPackLabelOut")
    public JsonResult addProductPackLabelOut(ProductPackLabelOut productPackLabelOut);

    /**
     * 查询所有设备
     * @return
     */
    @GetMapping("/device/admin/device/getAll")
    JsonResult<List<Device>> getDeviceAll();

    /**
     * 查询设备
     * @return
     */
    @GetMapping("/device/admin/device/list")
    PageResult<Device> getDevicePageList(
        @RequestParam("page") Integer page
        , @RequestParam("limit") Integer limit
        , @RequestParam(value = "sort", defaultValue = "create_time") String sort
        , @RequestParam(value = "order", defaultValue = "asc") String order
        , @RequestParam(value = "name") String name
        , @RequestParam(value = "deviceCode") String deviceCode);

    /**
     * 添加工序
     * @param deviceForm
     * @return
     */
    @PostMapping("/device/app/device/addDevice")
    JsonResult addDevice(@RequestBody DeviceForm deviceForm);

    /**
     * 查询工序下的设备
     * @return
     */
    @GetMapping("/product/admin/processDevice/deviceVOListByProcessId")
    JsonResult<List<ProcessDeviceVO>> deviceVOListByProcessId(@RequestParam("processId") Long processId);
    /**
     * 根据id查询设备
     * @return
     */
    @GetMapping("/device/admin/device/getDeviceById")
    JsonResult<DeviceVO> getDeviceById(@RequestParam("id") Long id);

    /**
     * 查询所有产品的skuCode和name
     * @return
     */
    @GetMapping("/product/admin/productDetail/getAll")
    JsonResult getProductDetailAll();
    /**
     * 查询所有产品单位
     * @return
     */
    @GetMapping("/product/admin/productUnit/getAll")
    JsonResult getProductUnitAll();
    /**
     * 查询所有包装方案
     * @return
     */
    @GetMapping("/product/admin/productPack/getAll")
    JsonResult getProductPackAll();

    /**
     * 查询在库产品列表
     * @return
     */
    @GetMapping("/product/admin/productDetailSKU/getInventoryProductDetailPageList")
    PageResult<ProductDetailVO> getInventoryProductDetailPageList(
            @RequestParam("page") Integer page,
            @RequestParam("limit") Integer limit,
            @RequestParam(value = "skuName", required = false) String skuName,
            @RequestParam(value = "skuCode", required = false) String skuCode,
            @RequestParam(value = "productTypeId", required = false) Long productTypeId,
            @RequestParam(value = "id", required = false) Long id,
            @RequestParam(value = "type", required = false) Integer type
    );

    @GetMapping("/product/admin/productDetail/list")
    PageResult<ProductDetailVO> getProductPageList(
            @RequestParam(name = "page") Integer page
            , @RequestParam(name = "limit") Integer limit
            , @RequestParam(name = "skuCode", required = false) String skuCode
            , @RequestParam(name = "productCategoryIds", required = false) String productCategoryIds
    );

    @GetMapping("/product/admin/productDetail/upById")
    JsonResult upById(@RequestParam("id") Long id, @RequestParam("num") Integer num);
    /**
     * 查询所有物流公司
     * @return
     */
    @GetMapping("/invoicing/admin/transportCompany/getAll")
    JsonResult getTransportCompanyAll();
    /**
     * 根据id查询物流公司
     * @return
     */
    @GetMapping("/invoicing/admin/transportCompany/getTransportCompanyById")
    JsonResult<TransportCompany> getTransportCompanyById(@RequestParam("id") Long id);

    /**
     *根據id查询企业信息
     */
    @GetMapping("/company/app/company/getCompanyInfo")
    JsonResult<Company> getCompanyInfo(@RequestParam("companyId") String companyId);

    /**
     *新增包装条码详情
     */
    @PostMapping("/product/admin/productPackLabelDetail/add")
    JsonResult addProductPackLabelDetail(@RequestBody ProductPackLabelDetailForm productPackLabelDetailForm);
    @GetMapping("/product/admin/productPackLabelDetail/getPackLabelDetaiListByJobId")
    JsonResult<List<ProductPackLabelDetailVO>> getPackLabelDetaiListByJobId(@RequestParam("jobId") Long jobId);


    /**
     * 根据skuCode查询库存
     * @param skuCode
     * @return
     */
    @GetMapping("/order/admin/cabInventoryProduct/getInventoryProduct")
    JsonResult<CabInventoryProduct> getCabInventoryProductVOBySkuCode(@RequestParam("skuCode") String skuCode);

    /**
     * 根据skuCode查询库存
     * @param warehouseId 仓库id
     * @param skuCode
     * @return
     */
    @GetMapping("/order/admin/cabInventoryProduct/getInventoryProduct2")
    JsonResult<CabInventoryProduct> getCabInventoryProductVOBySkuCode2(@RequestParam("skuCode") String skuCode, @RequestParam("warehouseId") Long warehouseId
            , @RequestParam("sourceType") Integer sourceType);
    /**
     * 添加产品库存
     * @param cabInventoryProductForm
     * @return
     */
    @PostMapping("/order/admin/cabInventoryProduct/add")
    JsonResult addCabInventoryProduct(@RequestBody CabInventoryProductForm cabInventoryProductForm);
    /**
     * 修改产品库存
     * @param cabInventoryProduct
     * @return
     */
    @PutMapping("/order/admin/cabInventoryProduct/updateCabInventoryProduct")
    JsonResult updateCabInventoryProduct(@RequestBody CabInventoryProduct cabInventoryProduct);

    /**
     * 添加产品库存记录
     * @param cabInventoryProductRecord
     * @return
     */
    @PostMapping("/order/admin/cabInventoryProductRecord/addCabInventoryProductRecord")
    JsonResult addCabInventoryProductRecord(@RequestBody CabInventoryProductRecord cabInventoryProductRecord);

    /**
     * 修改产品详情
     * @param skuCode
     * @return
     */
    @PutMapping("/product/admin/productDetail/updateProductDetail")
    JsonResult updateProductDetail(@RequestParam("skuCode") String skuCode);

    @PutMapping("/product/app/productPackLabel/saveSign")
    JsonResult saveSign(@RequestBody ScanDeliveryVo scanDeliveryVo);


   

    /**
     * 添加包装码记录数据
     * @param productPackLabelForm
     * @return
     */
    @PostMapping("/product/admin/productPackLabel/add")
    public JsonResult addProductPackLabel(@RequestBody ProductPackLabelForm productPackLabelForm);

    /**
     * 添加包装码记录数据
     * @param productPackLabelForm
     * @return
     */
    @PostMapping("/product/admin/productPackLabel/addNew")
    public JsonResult addProductPackLabelNew(@RequestBody ProductPackLabelForm productPackLabelForm);

    /*常用产品包从平台添加产品数据时数据写入knife_enterprise库的pro_product pro_product_detail表*/
    @PostMapping("/common/admin/common/syncProductAndDetailBatch")
    JsonResult syncProductAndDetailBatch(@RequestBody List<List<Map<String, Object>>> list);

    @PostMapping("/common/admin/common/syncProductAndDetail")
    JsonResult syncProductAndDetail(@RequestBody List<Map<String, Object>> list);

    @GetMapping("/product/app/productPackLabel/getLabelCode")
     JsonResult getLabelCode(@RequestParam("packLabelCode") String packLabelCode);

    @GetMapping("/system/admin/systemEnterprise/getSysEnterprise")
    JsonResult<SystemEnterpriseVO> getSysEnterprise(@RequestParam("settledCompanyId") Long settledCompanyId);


    @PostMapping("/area/getProvinceList")
    JsonResult getProvinceList();

    @PostMapping("/area/getCityList")
    JsonResult getCityList(@RequestParam("parentId") Integer parentId);


    @PostMapping("/area/getAreaList")
    JsonResult getAreaList(@RequestParam("parentId") Integer parentId);

    /**
     * 根据id查询品牌
     * @return
     */
    @GetMapping("/product/admin/productBrand/getProductBrandById")
    ProductBrandVO getProductBrandById(@RequestParam("id") Long id);

    @GetMapping("/product/admin/product/getProductByCode")
    JsonResult<List<Product>> getProductByCode(@RequestParam("productCode") String productCode);

    @GetMapping("/product/admin/productDetail/getProductDetailByCompanyIdAndSkuCode")
    JsonResult<List<ProductDetail>> getProductDetailByCompanyIdAndSkuCode(@RequestParam("settledCompanyId") Long settledCompanyId, @RequestParam("skuCode") String skuCode);

    @GetMapping("/product/admin/productDetail/getProductDetailByBarcode")
    JsonResult<List<ProductDetail>> getProductDetailByBarcode(@RequestParam("settledCompanyId") Long settledCompanyId, @RequestParam("barcode") String barcode);

    @GetMapping("/product/admin/productDetail/getProductDetailBySkuSpecValue")
    JsonResult<List<ProductDetail>> getProductDetailBySkuSpecValue(@RequestParam("productId") Long productId, @RequestParam("skuSpecValue") String skuSpecValue);
    @DeleteMapping("/order/admin/cabInventoryProduct/delete/{id}" )
    JsonResult InventoryDelete(@PathVariable("id") Long cabInventoryProductId);

    /**
     * 添加产品
     * @param productDetailForm
     * @return
     */
    @PostMapping("/product/admin/productDetail/add")
    JsonResult addProductDetail(@RequestBody ProductDetailForm productDetailForm);



    @GetMapping("/product/admin/productPackLabel/getByPurchaseId")
   JsonResult<List<ProductPackLabel>> getByPurchaseId(@RequestParam(value = "purchaseId") Long purchaseId, @RequestParam(value = "skuCode") String skuCode);

    @DeleteMapping("/order/admin/cabInventoryProduct/inventoryDeleteBySkuId" )
    JsonResult inventoryDeleteBySkuId(@RequestParam("skuId") Long skuId);
    //估计类型查询工序
    @GetMapping("/product/admin/processInfo/list")
    PageResult <ProcessInfoVO> getProcessInfoPageList(
            @RequestParam("page") Integer page,
            @RequestParam("limit") Integer limit,
            @RequestParam(value = "sort", defaultValue = "create_time") String sort,
            @RequestParam(value = "order", defaultValue = "asc") String order,
            @RequestParam(value = "productTypeId", required = false) Long productTypeId,
            @RequestParam(value = "code", required = false) String code,
            @RequestParam(value = "name", required = false) String name);

    /**
     * 添加工序
     * @param processInfoForm
     * @return
     */
    @PostMapping("/product/app/processInfo/add")
    JsonResult addProcessInfo(@RequestBody ProcessInfoForm processInfoForm);

    //查询工序物料
    @GetMapping("/product/admin/productProcessMaterial/list")
    PageResult <ProductProcessMaterialVO> getProcessMaterialPageList(
            @RequestParam("page") Integer page
            , @RequestParam("limit") Integer limit
            , @RequestParam(value = "sort", defaultValue = "create_time") String sort
            , @RequestParam(value = "order", defaultValue = "asc") String order
            , @RequestParam(value = "skuCode") String skuCode
            , @RequestParam(value = "processId") Long processId
            , @RequestParam(value = "defaultMaterialSkuCode", required = false) String defaultMaterialSkuCode);

    //根据id查询工序
    @GetMapping("/product/admin/processInfo/selectProcessInfoById")
    JsonResult<ProcessInfo> selectProcessInfoById(
            @RequestParam(value = "id") Long id);

    //查询所有工序
    @GetMapping("/product/admin/processInfo/getAllProcessInfo")
    JsonResult<List<ProcessInfo>> getAllProcessInfo();

    //查询销售订单
    @GetMapping("/sell/admin/order/getOrderById")
    JsonResult<OrderVO> getOrderById(@RequestParam("id") Long id, @RequestParam("skuCode") String skuCode);

    //查询生产管理正式订单
    @GetMapping("/sell/admin/order/getOrderPageList")
    PageResult<OrderVO> getOrderPageList(
            @RequestParam("page") Integer page
            , @RequestParam("limit") Integer limit
            , @RequestParam(value = "sort", defaultValue = "create_time") String sort
            , @RequestParam(value = "order", defaultValue = "asc") String order
            //, @RequestParam(value ="defaultMaterialSkuCode",required = false) String defaultMaterialSkuCode
            , @RequestParam(value = "code", required = false) String code
            , @RequestParam(value = "status", required = false) Order.Status status
            , @RequestParam(value = "orderSource", required = false) Order.OrderSource orderSource
            , @RequestParam(value = "orderType", required = false) Order.OrderType orderType
            , @RequestParam(value = "whetherList", required = false) Integer whetherList

    );

    /**
     * 添加系列
     * @param productForm
     * @return
     */
    @PostMapping("/product/admin/productSeries/add")
    JsonResult addProductSeries(@RequestBody ProductForm productForm);

    @GetMapping("/product/admin/productSeries/isOnlyName")
    JsonResult isOnlyProductSeriesName(@RequestParam(name = "name", required = false) String name,
                                       @RequestParam(name = "id", required = false) Long id);

    @GetMapping("/product/admin/productSeries/getProductByName")
    JsonResult<Product> getProductByName(@RequestParam(name = "name") String productName);

    /**
     * 对外开放的API接口列表(产品)
     * @param page
     * @param limit
     * @param name
     * @return
     */
    @GetMapping("/product/app/productSeries/foreignProductListAll")
    PageResult<Product> foreignProductListAll(@RequestParam(name = "page") Integer page,
                                              @RequestParam(name = "limit") Integer limit,
                                              @RequestParam(name = "name") String name,
                                              @RequestParam(name = "productCode") String productCode,
                                              @RequestParam(name = "specCode") String specCode);

    /**
     * 对外开放的API接口详情(产品)
     * @param id
     * @return
     */
    @GetMapping("/product/app/productSeries/foreignProductDetail")
    public JsonResult foreignProductDetail(@RequestParam(name = "id") Long id);

    /**
     * 对外开放的API接口列表(产品明细)
     * @param page
     * @param limit
     * @param skuName
     * @return
     */
    @GetMapping("/product/app/productDetail/foreignProductInfoListAll")
    public PageResult<ProductDetail> foreignProductInfoListAll(@RequestParam(name = "page") Integer page,
                                                               @RequestParam(name = "limit") Integer limit,
                                                               @RequestParam(name = "skuName") String skuName,
                                                               @RequestParam(name = "skuCode") String skuCode,
                                                               @RequestParam(name = "productId") Long productId,
                                                               @RequestParam(name = "startTime") String startTime,
                                                               @RequestParam(name = "endTime") String endTime);

    /**
     * 对外开放的API接口详情(产品明细)
     * @param id
     * @return
     */
    @GetMapping("/product/app/productDetail/foreignProductInfoDetail")
    public JsonResult foreignProductInfoDetail(@RequestParam(name = "id") Long id);

    //企业信息
    @GetMapping("/system/admin/systemOfficialInfo/getInfo")
    JsonResult<SystemOfficialInfo> getInfo();


    /**
     * 查询sku的质检信息
     * @param bookId 基准书id
     * @return
     */
    @GetMapping("/quality/admin/qualityTemplate/getQualityInfoBY/{bookId}")
    JsonResult getProQualityProjectBy(@PathVariable("bookId") Long bookId);



    /**
     * 添加客户产品目录
     * @param customerProductCatalogForm
     * @return
     */
    @PostMapping("/sell/admin/customerProductCatalog/addProduct")
    JsonResult addProduct(@RequestBody CustomerProductCatalogForm customerProductCatalogForm);


    /**
     * 添加评审任务
     * @param productReviewAddForm
     * @return
     */
    @PostMapping("/product/admin/productReview/addReviewInfoByOut")
    JsonResult addProductReview(@RequestBody ProductReviewAddForm productReviewAddForm);


    @GetMapping("/sell/admin/customerProductCatalog/getOutProductId/{code}")
    JsonResult getOutProductId(@PathVariable("code") String code);

    @GetMapping("/echnologyParam/admin/echnologyParam/getProcessInfoBy/{bookId}")
    List<ResBenchmarkBookEchnology> getProcessInfoBy(@PathVariable("bookId") Long bookId);

    @GetMapping("/echnologyParam/admin/echnologyParam/getProcessInfoByProcessId/{processId}")
    ResBenchmarkBookEchnology getProcessInfoByProcessId(@PathVariable("processId") Long processId);

    /**
     * 查询成品订单物料信息
     * @param orderId
     * @return
     */
    @GetMapping("/sell/admin/finishedOrder/getFinishDetailBy/{orderId}")
    List<OrderSkuDetailSearchVo> getFinishDetailBy(@PathVariable("orderId") Long orderId);

    /**
     * 获取销售正式订单详情
     * @param orderId
     * @return
     */
    @GetMapping("/sell/admin/massOrder/getOrderDetailBy/{orderId}")
    List<OrderSkuDetailSearchVo> getOrderDetailBy(@PathVariable("orderId") Long orderId);

    /**
     * 获取工序成品质检项
     *
     * @param bookId
     * @param processId
     * @return
     */
    @GetMapping("/echnologyParam/admin/echnologyParam/getQualityInfoBy/{bookId}/{processId}")
    List<ResBenchmarkBookEchnologyQuality> getQualityInfoBy(@PathVariable("bookId") Long bookId, @PathVariable("processId") Long processId);

    @PutMapping("/palletBoxSkuIterm/admin/palletBoxSkuIterm/update")
    JsonResult updatePalletBoxSkuIterm(@RequestBody PalletBoxSkuItermForm palletBoxSkuItermForm);

    @PostMapping("/receiptRecord/admin/receiptRecord/save")
    @ResponseBody
    JsonResult<ReceiptRecord> saveReceiptRecord(@RequestBody ReceiptRecord receiptRecord);
    
    @PostMapping("/receiptRecordDetail/admin/receiptRecordDetail/save")
    JsonResult saveReceiptRecordDetail(List<ReceiptRecordDetail> receiptRecordDetails);
}
